<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台首页</title>
    <link rel="stylesheet" href="/php/tpblog/public/BootStrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/php/tpblog/public/BootStrap/css/bootstrap-rtl.css" />
    <script type="text/javascript" src="/php/tpblog/public/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="/php/tpblog/public/BootStrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/php/tpblog/public/js/layer.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">بىلوگ سېستىىسى </a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li <?php if(CONTROLLER_NAME == 'Index'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Index/index');?>">باشبەت <span class="sr-only">(current)</span></a></li>
                <li <?php if(CONTROLLER_NAME == 'Category'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Category/index');?>">مەزمۇن</a></li>
                <li <?php if(CONTROLLER_NAME == 'User'): ?>class="active"<?php endif; ?>><a href="<?php echo U('User/index');?>">باشقۇرغۇچىلار</a></li>
                <li <?php if(CONTROLLER_NAME == 'Navs'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Navs/index');?>">ئىقتىدار</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/php/tpblog/index.php" target="_blank">ئالدى بەت</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">ياخشىمۇسىز <?php echo ($sessions['auser']); ?><span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <?php $a_aid=$sessions['aid'] ?>
                         <li><a href="<?php echo U('User/edit',array('aid'=>$a_aid));?>">ئارخىب تەھرىرلەش</a></li>
                        <li><a href="<?php echo U('Index/logout');?>">بىخەتەر چېكىنىش </a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="container">
    <div class="row">
        <div style="height: 30px"></div>
        <div class="col-md-2">
            <ul class="list-group">
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Category'): ?>active<?php endif; ?>"><a href="<?php echo U('Category/index');?>">سەھىپە باشقۇرۇش</a></li>
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Tag'): ?>active<?php endif; ?>"><a href="<?php echo U('Tag/index');?>">خەتكۈچ باشقۇرۇش</a></li>
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Article'): ?>active<?php endif; ?>"><a href="<?php echo U('Article/index');?>">خەۋەر باشقۇرۇش</a></li>
</ul>
<style>
    .list-group .active a{
        color: #fff;
    }
</style>

        </div>
        <div class="col-md-10">
            <div class="page-header">
                <h4>سەھىپە باشقۇرۇش</h4>
            </div>
            <div class="btn-group" role="group" aria-label="...">
                <a href="<?php echo U('Category/index');?>" class="btn btn-default">بارلىق سەھىپىلەر</a>
                <a href="<?php echo U('Category/add');?>" class="btn btn-default">يېڭىدىن قوشۇش</a>
            </div>
            <br/>
            <br/>
            <table class="table table-bordered">
                <thead>
                <tr class="active">
                    <td width="30">cid</td>
                    <td width="60">تەرتىپ</td>
                    <td>سەھىپە نامى</td>
                    <td>ھالىتى</td>
                    <td>مەشغۇلات</td>
                </tr>
                </thead>
                <tbody>
                    <?php if(is_array($categorys)): foreach($categorys as $key=>$c): ?><tr>
                            <td><?php echo ($c['cid']); ?></td>
                            <td><input class="form-control" type="text" onchange="jacascript:changgesort(this,<?php echo ($c['cid']); ?>);" value="<?php echo ($c['sort']); ?>"></td>
                            <td><?php if($c['pid'] != 0): echo str_repeat('&nbsp;',$c['level']*10);?>┘─&nbsp;<?php endif; echo ($c['cname']); ?></td>
                            <td>
                                <?php if($c['status']): ?><span class="label label-success">ئوچۇق</span>
                                    <?php else: ?>
                                    <span class="label label-danger">تاقاق</span><?php endif; ?>
                            </td>
                            <td>
                                <a href="<?php echo U('Category/edit',array('cid'=>$c['cid']));?>" class="btn btn-success btn-sm">تەھرىرلەش</a>
                                <a href="javascript:deCategory(<?php echo ($c['cid']); ?>)" class="btn btn-danger btn-sm">ئۆچۈرۈش</a>
                            </td>
                        </tr><?php endforeach; endif; ?>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script type="text/javascript">
    //分类排序
    function changgesort(obj,cid) {
        var csort=$(obj).val();
        $.ajax({
            'url':"<?php echo U('Category/changgeSort');?>",
            'type':'POST',
            'dataType':'json',
            'data':{'cid':cid,'sort':csort},
            success:function (phpRetrnData) {
                if(phpRetrnData.status){
                    layer.msg(phpRetrnData.message,{'icon':6},function () {
                        window.location=location;
                    })
                }
            }
        })
    }
    //删除提示框
   function deCategory(cid) {
       //询问框
       layer.confirm('راستىنلا ئۆچۈرەمسىز？', {
           btn: ['ھەئە','ياق'] //按钮
       }, function(){
           $.ajax({
               'url':"<?php echo U('Category/delete');?>",
               'type':'POST',
               'dataType':'json',
               'data':{'cid':cid},
               success:function (phpRetrnData) {
                   if(phpRetrnData.status){
                       layer.msg(phpRetrnData.massage,{'icon':6},function () {
                           window.location=location;
                       })
                   }else {
                       layer.msg(phpRetrnData.massage,{'icon':5});
                   }
               }
           })
       });
   }
</script>
</body>
</html>